﻿using System;
using System.Globalization;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#if NET20
namespace System.Net20.Tests
#elif NET35
namespace System.Net35.Tests
#elif NET40
namespace System.Net40.Tests
#elif NET45
namespace System.Net45.Tests
#elif NET451
namespace System.Net451.Tests
#elif PORTABLE40
namespace System.Portable40.Tests
#elif PORTABLE45
namespace System.Portable40.Tests
#endif
{
	[TestClass]
	public class UnixTImeTests
	{
		private static Random Rnd = new Random();
		private TestContext _testContext = null;

		public TestContext TestContext
		{
			get
			{
				return _testContext;
			}
			set
			{
				_testContext = value;
			}
		}

		#region Constructor Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DoubleConstructorTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime, target.DateTime.ToUniversalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LongConstructorTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampLong);
			Assert.AreEqual(data.DateTime, target.DateTime.ToUniversalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void IntConstructorTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampInt);
			Assert.AreEqual(data.DateTime, target.DateTime.ToUniversalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DateTimeConstructorTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(new DateTime(data.DateTime.Ticks, DateTimeKind.Utc));
			Assert.AreEqual(data.UnixTimestampDouble, target.Timestamp);
		}
		#endregion

		#region Public Member Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void TimestampPropertyTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.UnixTimestampDouble, target.Timestamp);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DateTimePropertyTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime.ToLocalTime(), target.DateTime);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DateTimeUtcPropertyTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime, target.DateTimeUtc);
		}
		#endregion

		#region Implicit Operator Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void UnixTimeToDoubleTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.UnixTimestampDouble, (double)target);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DoubleToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = data.UnixTimestampDouble;
			Assert.AreEqual(data.UnixTimestampDouble, target.Timestamp);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void UnixTimeToLongTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampLong);
			Assert.AreEqual(data.UnixTimestampLong, (long)target);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LongToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = data.UnixTimestampLong;
			Assert.AreEqual(data.UnixTimestampLong, (long)target.Timestamp);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void UnixTimeToDateTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime, ((DateTime)target).ToUniversalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DateTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = data.DateTime;
			Assert.AreEqual(data.UnixTimestampDouble, target.Timestamp);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void UnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime, ((DateTime)target).ToUniversalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void TimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan actual = TimeSpan.FromSeconds(data.UnixTimestampDouble);
			UnixTime target = actual;
			Assert.AreEqual(data.UnixTimestampDouble, actual.TotalSeconds);
		}
		#endregion

		#region Public Override Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void ToStringUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.UnixTimestampDouble.ToString(), target.ToString());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		public void EqualsNullUnixTimeTest()
		{
			UnixTime target = new UnixTime(DateTime.Now);
			Assert.IsFalse(target.Equals(null));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void EqualsUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			object target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1.Equals(target2));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void NotEqualUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			object target2 = new UnixTime(data.DateTime);

			Assert.IsFalse(target1.Equals(target2));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GetHashCodeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);

			Assert.AreEqual(target.GetHashCode(), data.UnixTimestampDouble.GetHashCode());
		}
		#endregion

		#region Static Member Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		public void EpochUnixTimeTest()
		{
			DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
			Assert.AreEqual(epoch, UnixTime.Epoch);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void FromDateTimeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);
			UnixTime target = UnixTime.FromDateTime(data.DateTime);
			Assert.AreEqual(target.Timestamp, data.UnixTimestampDouble);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LongToUniversalDateTimeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);
			UnixTime target = UnixTime.ToUniversalDateTime(data.UnixTimestampLong);
			Assert.AreEqual(target.DateTimeUtc, data.DateTime);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LongToLocalDateTimeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);
			UnixTime target = UnixTime.ToLocalDateTime(data.UnixTimestampLong);
			Assert.AreEqual(target.DateTime, data.DateTime.ToLocalTime());
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DoubleToUniversalDateTimeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);
			UnixTime target = UnixTime.ToUniversalDateTime(data.UnixTimestampDouble);
			Assert.AreEqual(target.DateTimeUtc, data.DateTime);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void DoubleToLocalDateTimeUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);
			UnixTime target = UnixTime.ToLocalDateTime(data.UnixTimestampDouble);
			Assert.AreEqual(target.DateTime, data.DateTime.ToLocalTime());
		}
		#endregion

		#region UnixTime/UnixTime Operator Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void AdditionOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			UnixTime target2 = target1 + value;

			Assert.AreEqual(target2.Timestamp, target1.Timestamp + value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void SubtractionOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			UnixTime target2 = target1 - value;

			Assert.AreEqual(target2.Timestamp, target1.Timestamp - value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void EqualsOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 == target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void NotEqualsOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 != target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble - 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 < target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorOrEqualToUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble - 1);
			UnixTime target2 = new UnixTime(data.DateTime.Subtract(TimeSpan.FromSeconds(1)));
			UnixTime target3 = new UnixTime(data.UnixTimestampDouble);

			Assert.IsTrue(target1 <= target2);
			Assert.IsTrue(target1 <= target3);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 > target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorOrEqualToUnixTimeToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime.Add(TimeSpan.FromSeconds(1)));
			UnixTime target3 = new UnixTime(data.UnixTimestampDouble);

			Assert.IsTrue(target1 >= target2);
			Assert.IsTrue(target1 >= target3);
		}
		#endregion

		#region UnixTime/TimeSpan Operator Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void AdditionOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			TimeSpan target2 = target1 + value;

			Assert.AreEqual(target2.TotalSeconds, target1.Timestamp + value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void SubtractionOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			TimeSpan target2 = target1 - value;

			Assert.AreEqual(target2.TotalSeconds, target1.Timestamp - value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void EqualsOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 == target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void NotEqualsOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 != target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble - 1);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 < target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorOrEqualToUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble - 1);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble + 1);
			TimeSpan target3 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 <= target2);
			Assert.IsTrue(target1 <= target3);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 > target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorOrEqualToUnixTimeToTimeSpanTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			TimeSpan target2 = TimeSpan.FromSeconds(data.UnixTimestampDouble + 1);
			TimeSpan target3 = TimeSpan.FromSeconds(data.UnixTimestampDouble);

			Assert.IsTrue(target1 >= target2);
			Assert.IsTrue(target1 >= target3);
		}
		#endregion

		#region TimeSpan/UnixTime Operator Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void AdditionOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			UnixTime target2 = target1.TotalSeconds + value;

			Assert.AreEqual(target2.Timestamp, target1.TotalSeconds + value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void SubtractionOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble);
			double value = Rnd.Next(1, 5000000);
			UnixTime target2 = target1.TotalSeconds - value;

			Assert.AreEqual(target2.Timestamp, target1.TotalSeconds - value);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void EqualsOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 == target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void NotEqualsOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 != target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble - 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 < target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void LessThanOperatorOrEqualToTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble - 1);
			UnixTime target2 = new UnixTime(data.DateTime.Subtract(TimeSpan.FromSeconds(1)));
			UnixTime target3 = new UnixTime(data.UnixTimestampDouble);

			Assert.IsTrue(target1 <= target2);
			Assert.IsTrue(target1 <= target3);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1 > target2);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void GreaterThanOperatorOrEqualToTimeSpanToUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			TimeSpan target1 = TimeSpan.FromSeconds(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime.Add(TimeSpan.FromSeconds(1)));
			UnixTime target3 = new UnixTime(data.UnixTimestampDouble);

			Assert.IsTrue(target1 >= target2);
			Assert.IsTrue(target1 >= target3);
		}
		#endregion

		#region UnixTime/Null Operator Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void EqualsOperatorUnixTimeToNullTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			Assert.IsFalse(target1 == null);
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void NotEqualOperatorUnixTimeToNullTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			Assert.IsTrue(target1 != null);
		}
		#endregion

		#region IComparable Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void IComparableTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			object target2 = new UnixTime(data.UnixTimestampDouble - 1);
			object target3 = new UnixTime(data.UnixTimestampDouble);
			object target4 = new UnixTime(data.UnixTimestampDouble + 1);

			Assert.AreEqual(1, target1.CompareTo(target2), "+1");
			Assert.AreEqual(0, target1.CompareTo(target3), "0");
			Assert.AreEqual(-1, target1.CompareTo(target4), "-1");
			Assert.AreEqual(-1, target1.CompareTo(null), "+1");
		}
		#endregion

		#region IFormattable Tests
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void ToStringFormatTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime.ToLocalTime().ToString("f"), target.ToString("f"));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void ToStringFormatProviderTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			CultureInfo culture = new CultureInfo("fr-FR");
			UnixTime target = new UnixTime(data.UnixTimestampDouble);
			Assert.AreEqual(data.DateTime.ToLocalTime().ToString("f", culture), target.ToString("f", culture));
		}
		#endregion

		#region IComparable<UnixTime> Test
		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void IComparableUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			UnixTime target2 = new UnixTime(data.UnixTimestampDouble - 1);
			UnixTime target3 = new UnixTime(data.UnixTimestampDouble);
			UnixTime target4 = new UnixTime(data.UnixTimestampDouble + 1);

			Assert.AreEqual(1, target1.CompareTo(target2), "+1");
			Assert.AreEqual(0, target1.CompareTo(target3), "0");
			Assert.AreEqual(-1, target1.CompareTo(target4), "-1");
			Assert.AreEqual(-1, target1.CompareTo(null), "+1");
		}
		#endregion

		#region IEquatable<UnixTime> Test
		[TestMethod]
		[TestCategory("Constructor Tests")]
		public void IEquatableEqualsNullUnixTimeTest()
		{
			UnixTime target = new UnixTime(DateTime.Now);
			Assert.IsFalse(target.Equals(null));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void IEquatableEqualsUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsTrue(target1.Equals(target2));
		}

		[TestMethod]
		[TestCategory("Constructor Tests")]
		[DeploymentItem("UnixTimeTestData.xlsx")]
		[DataSource("System.Data.OleDb", "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=UnixTimeTestData.xlsx;Extended Properties=\"Excel 12.0;HDR=YES\"", "UnixTime$", DataAccessMethod.Sequential)]
		public void IEquatableNotEqualUnixTimeTest()
		{
			TestDataItem data = TestDataItem.FromDataRow(this.TestContext.DataRow);

			UnixTime target1 = new UnixTime(data.UnixTimestampDouble + 1);
			UnixTime target2 = new UnixTime(data.DateTime);

			Assert.IsFalse(target1.Equals(target2));
		}
		#endregion
	}
}
